# Build recipe for doxygen.
#
# Copyright (c) 2018 Markus Tornow, <tornow@riseup.net>.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

program=doxygen
version=1.8.14
release=1

# Set 'outdir' for a nice and well-organized output directory
outdir="${outdir}/${arch}/devel"

tarname=${program}-${version}.src.tar.gz

# Remote source(s)
fetch=http://ftp.stack.nl/pub/users/dimitri/"$tarname"

description="
Tool to generate documentation from C++ sources. 

Doxygen can help you in three ways:
1. It can generate an on-line documentation browser (in HTML) and/or an
off-line reference manual (in LaTeX) from a set of documented source
files.  There is also support for generating output in RTF (MS-Word),
PostScript, hyperlinked PDF, compressed HTML, DocBook and Unix man
pages.  The documentation is extracted directly from the sources, which
makes it much easier to keep the documentation consistent with the
source code.  
2. You can configure doxygen to extract the code
structure from undocumented source files. This is very useful to
quickly find your way in large source distributions. Doxygen can also
visualize the relations between the various elements by means of
include dependency graphs, inheritance diagrams, and collaboration
diagrams, which are all generated automatically.  
3. You can also usedoxygen for creating normal documentation (as I did
for Doxygen is the de facto standard tool for generating documentation
from annotated C++ sources, but it also supports other popular
programming languages such as C, Objective-C, C#, PHP, Java, Python,
IDL (Corba, Microsoft, and UNO/OpenOffice flavors), Fortran, VHDL, Tcl,
and to some extent D.
"

homepage=http://www.doxygen.org/
license="GPLv2"

# Source documentation
docs="LICENSE README.md "
docsdir="${docdir}/${program}-${version}"

build()
{
    set -e

    unpack "${tardir}/$tarname"

    cd "$srcdir"


    cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX:PATH=/usr/  
   
    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 '{}' +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    # Copy documentation
    mkdir -p "${destdir}${docsdir}"
    cp -p $docs "${destdir}${docsdir}/"
}


